import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StoreVO, StoreForm, StoreQuery } from '@/api/merchants/store/types';

/**
 * 查询商家列表
 * @param query
 * @returns {*}
 */

export const listStore = (query?: StoreQuery): AxiosPromise<StoreVO[]> => {
  return request({
    url: '/merchants/store/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询商家下拉列表
 * @returns {*}
 */
export const listStoreOption = (): AxiosPromise<StoreVO[]> => {
  return request({
    url: '/merchants/store/option',
    method: 'get'
  });
};

/**
 * 查询商家详细
 * @param id
 */
export const getStore = (id: string | number): AxiosPromise<StoreVO> => {
  return request({
    url: '/merchants/store/' + id,
    method: 'get'
  });
};

/**
 * 新增商家
 * @param data
 */
export const addStore = (data: StoreForm) => {
  return request({
    url: '/merchants/store',
    method: 'post',
    data: data
  });
};

/**
 * 修改商家
 * @param data
 */
export const updateStore = (data: StoreForm) => {
  return request({
    url: '/merchants/store',
    method: 'put',
    data: data
  });
};

/**
 * 删除商家
 * @param id
 */
export const delStore = (id: string | number | Array<string | number>) => {
  return request({
    url: '/merchants/store/' + id,
    method: 'delete'
  });
};
